<?php
namespace app\admin\controller;

use app\admin\library\traits\BackApi;
use app\admin\services\AdminServices;
use app\admin\validate\Auth\AdminValidate;
use support\exception\Exception;
use support\Request;

class Login extends BackApi
{

    public function login(Request $request)
    {
        [$username, $password] = $request->onlyData(['username', 'password']);
        //验证数据
        validate(AdminValidate::class , ['username' => $username, 'password' => $password] , 'get');
        //验证登录
        $adminServices = new AdminServices();
        $result = $adminServices->login($username , $password);
        return $this->success("成功" , $result );
    }

}